package com.kinyx.framework.db.sentence.res;

import org.junit.Test;

import com.kinyx.framework.db.sentence.CompareType;
import com.kinyx.framework.utils.KEnumUtils;

public class _Expression_COMPARE_Tester_ extends SUPER {

	public void test(final String tableAlias, final int tableIdx, final Column column, final String columnName, final String fieldName, final Object param) {
		KEnumUtils.iterator(CompareType.class, e -> {
			final _Expression_COMPARE expression = new _Expression_COMPARE(column.idx(tableIdx), e, param);

			final String sentence1 = columnName + " " + e.getValue() + " ?";
			final String sentence2 = fieldName + " " + e.getValue() + " ?";
			final String sentence3 = tableAlias + (tableIdx == 0 ? "" : tableIdx) + "." + sentence1;
			final String sentence4 = tableAlias + (tableIdx == 0 ? "" : tableIdx) + "." + sentence2;

			this.test_getSentence(expression, //
					sentence1, //
					sentence2, //
					sentence3, //
					sentence4 //
			);
			this.test_toString(expression, //
					"SQL: [" + sentence1 + "], param: [" + param + "]", //
					"HQL: [" + sentence2 + "], param: [" + param + "]", //
					"SQL: [" + sentence3 + "], param: [" + param + "]", //
					"HQL: [" + sentence4 + "], param: [" + param + "]" //
			);
		});
	}

	@Test
	public void test() {
		this.list_tableIdx.forEach(tableIdx -> {
			this.list_column.forEach(column -> {
				this.list_param.forEach(param -> {
					this.test("demoEntity", tableIdx, column.column, column.columnName, column.fieldName, param);
				});
			});
		});
	}

}
